package com.xdjd.task.service.daoservice;

import com.xdjd.task.mapper.activity.ActivityUserClockPoDao;
import com.xdjd.task.model.activity.ActivityUserClockPo;
import net.oschina.durcframework.easymybatis.query.Query;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ActivityUserClockPoService {

    @Autowired
    private ActivityUserClockPoDao activityUserClockPoDao;

    public void endClock() {
        activityUserClockPoDao.endClock();
    }

    public List<ActivityUserClockPo> findAllOngoing() {
        Query query = new Query().eq("status", 1);
        return activityUserClockPoDao.findAll(query);
    }

    public int reduceRemainDay(String clockNo) {
        return activityUserClockPoDao.reduceRemainDay(clockNo);
    }

    public ActivityUserClockPo findByMemberId(Long memberId) {
        Query query = new Query().eq("member_id", memberId).eq("status", 1);
        return activityUserClockPoDao.getByExpression(query);
    }
}
